package com.ashin.xmemcached;

import java.util.concurrent.TimeUnit;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ashin.cache.bean.Student;
import com.ashin.spring.cache.ICache;

/**
 * memcache和spring集成demo
 * 
 * @author Ashin
 *
 */
public class XMemcacheSpringTest {

    public static void main(String... args) throws InterruptedException {
        // 使用"spring.xml"和"spring-mybatis.xml"这两个配置文件创建Spring上下文
        ApplicationContext ac = new ClassPathXmlApplicationContext(new String[] { "xmemcached-context.xml" });

        ICache bean = ac.getBean(ICache.class);

        Student s = new Student();
        s.setAge(11);
        s.setName("zjh");

        bean.set("s2", s, 10);
        for (int i = 0; i < 20; i++) {
            TimeUnit.SECONDS.sleep(1);
            System.out.println(bean.get("s2"));
        }

    }

}
